package com.source.multithread.run;

import java.util.concurrent.*;

/**
 * @Author wengqy
 * @Date 2020/12/19
 */
public class CallableDemo  implements Callable<String> {
    private static      int num =200;
    @Override
    public String call() throws Exception {
       /* System.out.println(Thread.currentThread().getName());*/

        if(num>0){
            for (int i = 0; i <100 ; i++) {
                Thread.sleep(100);
                System.out.println(Thread.currentThread().getName()+"......"+i);
            }
            num--;
        }




        return "success";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallableDemo  callableDemo = new CallableDemo();
        Thread.sleep(100);
        ExecutorService executorService = Executors.newFixedThreadPool(4);
        Future<String> submit = executorService.submit(callableDemo);
        Thread.sleep(100);
        String s = submit.get();
        System.out.println(s);
        System.out.println("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");

    }
}
